<template>
  <DataList
   :cate="cate" 
   :cols="cols"
   :single="true"
    :name="name" />
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import { addPjqk, deletePjqk, updatePjqk, getPjqk } from "@/api/评教情况.js";
import { mkdir } from 'fs';
export default {
  components: {
    DataList
  },
  data() {
    return {
      cate: "A8-7评教情况",
       name:'8.7 评教情况',
      cols: [
        { label: "评教起始日期(年月)", prop: "QSRQ" },
        { label: "评教终止日期(年月)", prop: "ZZRQ" },
        {
          label: "评教客体(教师)",
          data: [
            { label: "参与数(人)", prop: "PJKT_CYS" },
            { label: "总数(人)", prop: "PJKT_ZS" },
            { label: "评价客体(教师)覆盖面(%)", prop: "PJKT_FGM" },
          ]},
          
       {
           label: "评教主体参与度",
           data: [
               { 
                 label: "学生", 
                 data:[
                 { label: "参与数(人)", prop: "PJCYD_XS_CYS" },
                 { label: "总数(人)", prop: "PJCYD_XS_ZS" },
                 { label: "参与比例(%)", prop: "PJCYD_XS_BL" },
                 ] ,
                  
                   },
                   {
                  label: "同行",
                  data:[
                 { label: "参与数(人)", prop: "PJCYD_TH_CYS" },
                 { label: "总数(人)", prop: "PJCYD_TH_ZS" },
                 { label: "参与比例(%)", prop: "PJCYD_TH_BL" },
                 ] ,
                   }, 
                   {
                  label: "校领导",
                  data:[
                 { label: "参与数(人)", prop: "PJCYD_XLD_CYS" },
                 { label: "总数(人)", prop: "PJCYD_XLD_ZS" },
                 { label: "参与比例(%)", prop: "PJCYD_XLD_BL" },
                 ] ,
                   }, {
                  label: "社会",
                  data:[
                 { label: "参与数(人)", prop: "PJCYD_SH_CYS" },
                 { label: "总数(人)", prop: "PJCYD_SH_ZS" },
                 { label: "参与比例(%)", prop: "PJCYD_SH_BL" },
                 ] ,
                   },             
             
           ]},
          
        
      ]
    };
  },
  methods: {

    async onChange(model,feild,value){
      model.PJKT_FGM=((Number(model.PJKT_CYS)/Number(model.PJKT_ZS))*100).toFixed(2)+''
      model.PJCYD_XS_BL=((Number(model.PJCYD_XS_CYS)/Number(model.PJCYD_XS_ZS))*100).toFixed(2)+''
      model.PJCYD_TH_BL=((Number(model.PJCYD_TH_CYS)/Number(model.PJCYD_TH_ZS))*100).toFixed(2)+''
      model.PJCYD_XLD_BL=((Number(model.PJCYD_XLD_CYS)/Number(model.PJCYD_XLD_ZS))*100).toFixed(2)+''
      model.PJCYD_SH_BL=((Number(model.PJCYD_SH_CYS)/Number(model.PJCYD_SH_ZS))*100).toFixed(2)+''
    },
      async fetchData() {
      var user = getUser();
      var datas = await getPjqk(user.XXID,user.CJPC);
      return datas;
    },
     onadd(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
      
          console.log(JSON.stringify(temp));
          var model = await addPjqk(temp);
          resolve(model);
      })
      
    },
    onupdate(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
          console.log(JSON.stringify(temp));
          var model = await updatePjqk(temp);
          resolve(model);
      })
      //
    },
    ondelete(model) {
       var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
        
         await deletePjqk(temp);
          resolve();
      })
    }
  }
};
</script>
<style>
</style>